//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;


int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	int n, m, i, j, a, b, c, d;
	char s[50][51];
	
	scanf("%d%d", &n, &m);
	
	for(i=0;i<n;++i){
		scanf("%s", s[i]);
	}
	
	b=d=0;
	a=c=200;
	for(i=0;i<n;++i){
		for(j=0;j<m;++j){
			if(s[i][j]=='*'&&i<a)a=i+1;
			if(s[n-i-1][j]=='*'&&(n-i>b))b=n-i;
			if(s[i][j]=='*'&&j<c)c=j+1;
			if(s[i][m-j-1]=='*'&&(m-j>d))d=m-j;
		}
	}
	for(i=a-1;i<b;++i){
		for(j=c-1;j<d;++j){
			printf("%c", s[i][j]);
		}
		printf("\n");
	}

	
	return 0;
}
